# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=ldns

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.6.17
pkgrel=1
pkgdesc="Fast DNS library supporting recent RFCs (mingw-w64)"
arch=('any')
url='http://www.nlnetlabs.nl/projects/ldns/'
license=('custom:BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-openssl"
     "${MINGW_PACKAGE_PREFIX}-dnssec-anchors"
    )
options=(strip staticlibs)
source=("http://www.nlnetlabs.nl/downloads/${_realname}/${_realname}-${pkgver}.tar.gz")
sha1sums=('4218897b3c002aadfc7280b3f40cda829e05c9a4')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --sysconfdir=${MINGW_PREFIX}/etc \
    --localstatedir=${MINGW_PREFIX}/var \
    --with-drill \
    --without-examples \
    --without-pyldns
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
